using CardGameObject.Common;
using Entity;
using TMPro;
using UnityEngine;
using Utils;

// 添加 SceneManager 命名空间

namespace CardGameObject.DeckScene
{
    public class CollectDeck : MonoBehaviour // 实现 IPointerClickHandler 接口
    {
        // Deck本身属性

        // Deck展示属性
        public TextMeshPro NameText;
        public SpriteRenderer DeckImage;

        public string DeckName { get; set; }

        public string DeckCard { get; set; }

        public Deck Deck { get; set; }

        // 被点击时触发场景跳转
        private void OnMouseDown()
        {
            if (Deck == null) return;
            // 假设 Deck 类有一个 Id 属性
            PlayerPrefs.SetInt("DeckId", (int)Deck.DeckId);
            // 加载 CollectScene 场景
            GlobalSceneManager.LoadSceneByName("CollectScene");
        }

        public void SetDeckInfo()
        {
            if (Deck != null)
            {
                BeanUtil.CopyProperties(Deck, this);
            }

            NameText.text = DeckName;

            Sprite sprite = Resources.Load<Sprite>($"Images/DeckImage/Content/{DeckName}");
            if (sprite)
            {
                DeckImage.sprite = sprite;
            }
        }
    
    }
}
